package tt.dz.biz.dao.card;

import java.util.List;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Repository;
import tt.dz.biz.dao.BaseDAO;
import tt.dz.vo.OuterCardTypeVO;

@Repository("outerCardTypeDAO")
public class OuterCardTypeDAO
  extends BaseDAO
{
  private static final String QUERY_ALL_OUTER_CARD_TYPE_ = "select  card_bin ,card_type,card_type_name,is_valid from ms_outer_card_type where is_valid = 1";
  
  public OuterCardTypeVO queryOuterCardTypeByCardBin(String cardBin)
  {
    try
    {
      StringBuilder sql = new StringBuilder("select  card_bin ,card_type,card_type_name,is_valid from ms_outer_card_type where is_valid = 1");
      sql.append(" and card_bin=:cardBin ");
      OuterCardTypeVO param = new OuterCardTypeVO();
      param.setCardBin(cardBin);
      return (OuterCardTypeVO)queryForObject(sql.toString(), param, OuterCardTypeVO.class);
    }
    catch (EmptyResultDataAccessException e) {}
    return null;
  }
  
  public List<OuterCardTypeVO> queryAllOuterCardType()
  {
    return queryForList("select  card_bin ,card_type,card_type_name,is_valid from ms_outer_card_type where is_valid = 1", null, OuterCardTypeVO.class);
  }
}
